package com.amrit.revision;

public class Parent {

	public static void main(String[] args) {

		try {
			Parent a = new Parent();
			Parent a1 = new Child(); // Dynamic dispatch - runtime polymorphism - Upcasting
			Child b = new Child();
			//Child b1 = (Child)new Parent(); // Downcasting
			Child b1 = (Child)a;
			b1.m1();
			/*
			 * a.m1(); a.m2();
			 */

			a1.m1();
			a.m2();
			System.out.println("-------------");
			b.m1();
			b.m2();
			b.m3();
			System.out.println(a instanceof Child);
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	void m1() {
		System.out.println("Inside m1 of A");
	}

	void m2() throws MyCustomException {
		System.out.println("Inside m2 of A");
	}

}
